package com.yorick.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
@Lazy(false)
public class SpringTools implements ApplicationContextAware{

	private static ApplicationContext applicationContext = null;  
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		if (SpringTools.applicationContext == null) {
		SpringTools.applicationContext = applicationContext;
		}
		}

public static ApplicationContext getApplicationContext() {
		return applicationContext;
		}

public static Object getBean(String name) {
		return getApplicationContext().getBean(name);
		}
		}
